package cn.edu.bupt.freewings.forum.client.rest;

import cn.edu.bupt.freewings.forum.client.base.ClientUtility;
import cn.edu.bupt.freewings.forum.client.Constants;
import cn.edu.bupt.freewings.forum.common.PostType;
import cn.edu.bupt.freewings.forum.common.CommonType;

public class PostClient {
	public PostType.PostList getByTopicId(Integer topicId, Integer start,
			Integer number) {
		String query = "/" + topicId + "?start=" + start + "&number=" + number;
		return (PostType.PostList) ClientUtility.makeHttpRequest(
				ClientUtility.HTTPMethod.GET, Constants.REST_SERVER + Constants.POSTS
						+ query, null, null, Constants.MIME_PROTO, PostType.PostList.class);
	}

	public void put(PostType.Post post) {
		ClientUtility.makeHttpRequest(ClientUtility.HTTPMethod.PUT,
				Constants.REST_SERVER + Constants.POST + "/new", Constants.MIME_PROTO, post
						.toByteArray(), Constants.MIME_PROTO, CommonType.Empty.class);
	}
}
